/**
 * @author ens12ilt - ens12ple
 */

package config;

import java.util.HashMap;

public final class Config {

	public static boolean IMAGE_PROCESSING = true;
	public static boolean DEBUG = false;
	public static double TOLERATED_ERROR = Math.pow(10, -3);
	public static double SAME_ERROR = Math.pow(10, -3);
	public static double LEARNING_RATE = 0.15;
	public static int NB_HIDDEN_LAYER = 2;

	public static String KEY_IMG_LEARNING_FILE = "ilf";
	public static String KEY_ANSWER_LEARNING_FILE = "alf";
	public static String KEY_IMG_GUESSING_FILE = "igf";
	public static String KEY_LEARNING_RATE = "lr";
	public static String KEY_TOLERATED_ERROR = "te";
	public static String KEY_NB_HIDDEN = "nhl";
	public static String KEY_TO_GUESS_FILE = "igf";
	public static String KEY_TO_GUESS_ANSWER_FILE = "igaf";

	private Config(){}

	public static HashMap<String, String> argManager(String[] args) {	
		HashMap<String, String> params = new HashMap<String, String>();	
		if(args.length < 3){
			System.out.println("Usage : ... ");
			System.exit(0);
		} else{
			params.put(Config.KEY_IMG_LEARNING_FILE, args[0]);
			params.put(Config.KEY_ANSWER_LEARNING_FILE, args[1]);
			params.put(Config.KEY_TO_GUESS_FILE, args[2]);

			// Arguments management 
			for(int i = 2; i < args.length - 1; i++){
				if(args[i].matches("-" + Config.KEY_LEARNING_RATE)){
					params.put(Config.KEY_LEARNING_RATE, args[i+1]);
				}
				if(args[i].matches("-" + Config.KEY_TOLERATED_ERROR)){
					params.put(Config.KEY_TOLERATED_ERROR, args[i+1]);
				}
				if(args[i].matches("-" + Config.KEY_NB_HIDDEN)){
					params.put(Config.KEY_NB_HIDDEN, args[i+1]);
				}
			}
			if(params.containsKey(Config.KEY_LEARNING_RATE)){
				Config.LEARNING_RATE = Double.parseDouble(params.get(Config.KEY_LEARNING_RATE));
			}
			if(params.containsKey(Config.KEY_TOLERATED_ERROR)){
				Config.TOLERATED_ERROR = Double.parseDouble(params.get(Config.KEY_TOLERATED_ERROR));
			}
			if(params.containsKey(Config.KEY_NB_HIDDEN)){
				Config.NB_HIDDEN_LAYER = Integer.parseInt(params.get(Config.KEY_NB_HIDDEN));
			}
		}
		return params;
	}
}
